feat(upgrade): Sign-in Client Trust status handling#7446
Conversation
🦋 Changeset detectedLatest commit: 456bc24 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdds a changeset entry and documentation for a new Sign-in status Changes
Estimated code review effortMedium — ~25 minutes Areas requiring focused review:
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
@brkalow Added the "force display" option we were discussing earlier. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/upgrade/src/versions/core-3/changes/needs-client-trust-sign-in-status-added.md (2)
8-8: TODO reminder: Documentation link placeholder.The documentation link is pending. Per the PR description, this will be updated when documentation is ready.
Would you like me to open an issue to track this TODO, or is this already being handled as part of the PR workflow?
15-15: Minor: Improve phrasing for clarity.The phrasing "If ... aren't enabled" in the prerequisite list could be clearer. Consider rewording to "If Email or SMS sign-in verification is not enabled."
Apply this diff:
-- If [Email](https://dashboard.clerk.com/~/user-authentication/user-and-authentication) or [SMS](https://dashboard.clerk.com/~/user-authentication/user-and-authentication?user_auth_tab=phone) sign-in verification aren't enabled. +- If [Email](https://dashboard.clerk.com/~/user-authentication/user-and-authentication) or [SMS](https://dashboard.clerk.com/~/user-authentication/user-and-authentication?user_auth_tab=phone) sign-in verification is not enabled.packages/upgrade/src/runner.js (1)
137-146: Consider renamingloadMatchersto reflect its broader purpose.The function
loadMatchersnow returns all changes (both with and without matchers) that match the SDK, not just those with matchers. Consider renaming toloadChangesorloadApplicableChangesfor better clarity.Apply this diff:
-function loadMatchers(config, sdk) { +function loadChanges(config, sdk) { if (!config.changes) { return []; } return config.changes.filter(change => { const packages = change.packages || ['*']; return packages.includes('*') || packages.includes(sdk); }); }And update the call site:
export async function runScans(config, sdk, options) { - const changes = loadMatchers(config, sdk); + const changes = loadChanges(config, sdk);
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
.changeset/small-dots-scream.md(1 hunks)packages/upgrade/src/__tests__/integration/runner.test.js(2 hunks)packages/upgrade/src/runner.js(2 hunks)packages/upgrade/src/versions/core-3/changes/needs-client-trust-sign-in-status-added.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
All code must pass ESLint checks with the project's configuration
Files:
packages/upgrade/src/__tests__/integration/runner.test.jspackages/upgrade/src/runner.js
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/upgrade/src/__tests__/integration/runner.test.jspackages/upgrade/src/runner.jspackages/upgrade/src/versions/core-3/changes/needs-client-trust-sign-in-status-added.md
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Follow established naming conventions (PascalCase for components, camelCase for variables)
Files:
packages/upgrade/src/__tests__/integration/runner.test.jspackages/upgrade/src/runner.js
packages/**/src/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
packages/**/src/**/*.{ts,tsx,js,jsx}: Maintain comprehensive JSDoc comments for public APIs
Use tree-shaking friendly exports
Validate all inputs and sanitize outputs
All public APIs must be documented with JSDoc
Use dynamic imports for optional features
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Implement proper logging with different levels
Files:
packages/upgrade/src/__tests__/integration/runner.test.jspackages/upgrade/src/runner.js
**/*.{test,spec}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
**/*.{test,spec}.{ts,tsx,js,jsx}: Unit tests are required for all new functionality
Verify proper error handling and edge cases
Include tests for all new features
Files:
packages/upgrade/src/__tests__/integration/runner.test.js
**/*.{test,spec,e2e}.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Use real Clerk instances for integration tests
Files:
packages/upgrade/src/__tests__/integration/runner.test.js
**/*.{js,ts,jsx,tsx}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use ESLint with custom configurations tailored for different package types
Files:
packages/upgrade/src/__tests__/integration/runner.test.jspackages/upgrade/src/runner.js
**/*.{js,ts,jsx,tsx,json,md,yml,yaml}
📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)
Use Prettier for code formatting across all packages
Files:
packages/upgrade/src/__tests__/integration/runner.test.jspackages/upgrade/src/runner.jspackages/upgrade/src/versions/core-3/changes/needs-client-trust-sign-in-status-added.md
**/*.{md,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development.mdc)
Update documentation for API changes
Files:
packages/upgrade/src/versions/core-3/changes/needs-client-trust-sign-in-status-added.md
🧬 Code graph analysis (1)
packages/upgrade/src/runner.js (1)
packages/upgrade/src/config.js (3)
config(29-29)config(53-53)matcher(164-168)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (7)
.changeset/small-dots-scream.md (1)
1-5: LGTM!The changeset is correctly formatted with an appropriate patch version bump for adding the new Sign-in Client Trust Status entry.
packages/upgrade/src/versions/core-3/changes/needs-client-trust-sign-in-status-added.md (1)
19-27: LGTM!The code example effectively demonstrates how to handle the new
needs_client_truststatus alongside the existingcompletestatus. The diff format makes the required changes clear.packages/upgrade/src/runner.js (2)
62-82: LGTM! Clear separation of concerns.The refactoring correctly splits changes into those with and without matchers, ensuring changes without matchers are always included in results with empty instances. The early return optimization when there are no changes with matchers is a good performance improvement.
99-126: LGTM! Scanning logic correctly handles matcher-based changes.The scanning loop now correctly iterates only over
changesWithMatchers, accumulating matches into the results object that was pre-populated with changes without matchers. The duplicate detection logic ensures clean results.packages/upgrade/src/__tests__/integration/runner.test.js (3)
59-60: LGTM! Important fix for the ignore patterns test.Filtering to only changes with matchers ensures this test validates the ignore functionality correctly without being affected by changes without matchers that would always appear in results.
72-97: LGTM! Comprehensive test for changes without matchers.The test correctly validates that changes without matchers are always included in results with an empty instances array, which is the core new behavior introduced in this PR.
99-135: Good test coverage for mixed scenarios.The test validates that both changes with and without matchers appear in results. The assertions correctly verify the presence of the change without a matcher and its empty instances array.
One minor observation: Line 131 uses
toBeGreaterThanOrEqual(1)which is somewhat weak. However, given the dynamic nature of the matcher-based change (it may or may not find matches in the fixture), this assertion level is acceptable.
3a4a7e4 to
363c26c
Compare
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
| - signIn.attemptFirstFactor({ strategy: 'password', password: '...' }) | ||
| - if (signIn.status === 'complete') {/* ... */ } | ||
| + const { signIn } = useSignIn() | ||
| + signIn.attemptFirstFactor({ strategy: 'password', password: '...' }) |
There was a problem hiding this comment.
if we remove this line the example will be compatible for both the new hooks and the included legacy hooks
| + signIn.attemptFirstFactor({ strategy: 'password', password: '...' }) |
There was a problem hiding this comment.
also maybe this is a better way to visualize this?
const { signIn } = useSignIn()
// ...
- if (signIn.status === 'complete') { /* ... */ }
+ if (signIn.status === 'needs_client_trust') { /* ... */ }
+ else if (signIn.status === 'complete') { /* ... */ }```diff
const { signIn } = useSignIn()
// ...
- if (signIn.status === 'complete') { /* ... */ }
+ if (signIn.status === 'needs_client_trust') { /* ... */ }
+ else if (signIn.status === 'complete') { /* ... */ }
```There was a problem hiding this comment.
👍 I definitely like this more. Thanks!
1841056 to
456bc24
Compare
Description
needs_client_trustmatcherfrontmatter to indicate that the change should always be displayed.needs_client_truststatus clerk-docs#3096Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
New Features
Documentation
Tests
Chores